﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Stack
{
    public class ArrayStack<E> : Stack<E>
    {
        Array<E> array;
        public ArrayStack()
        {
            array = new Array<E>();
        }
        public ArrayStack(int capacity)
        {
            array = new Array<E>(capacity);
        }
        public int getsize()
        {
            return array.GetSize();
        }

        public int GetCapacity()
        {
            return array.GetCapacity();
        }

        public bool isEmpty()
        {
            return array.IsEmpty();
        }

        public E peek()
        {
            return array.GetLast();
        }

        public E pop()
        {
            return array.RemoveLast();
        }

        public void push(E e)
        {
            array.AddLast(e);
        }


        public override string ToString()
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("[");
            for (int i = 0; i < array.GetSize(); i++)
                stringBuilder.Append(i != array.GetSize() - 1 ? array.Get(i).ToString() + "," : array.Get(i).ToString());
            stringBuilder.Append("] top");
            return stringBuilder.ToString();
        }

    }
}
